package com.liyunc.socket.keepalive.logger;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Logger {

    private static final String TAG = "[KEEP_ALIVE]";
    private static final String INFO = "[INFO]";

    /**
     * 打印信息
     *
     * @param message
     */
    public static void info(String message) {
        String time = "[" + refFormatNowDate() + "]";
        message = String.format("%s%s%s:%s", TAG, INFO, time, message);
        System.out.println(message);
    }

    /**
     * 打印错误信息
     *
     * @param message
     */
    public static void error(String message) {
        String time = "[" + refFormatNowDate() + "]";
        message = String.format("%s%s%s:%s", TAG, INFO, time, message);
        System.err.println(message);
    }


    private static String refFormatNowDate() {
        SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm:ss:ssss");
        return sdf.format(new Date(System.currentTimeMillis()));
    }
}
